function rest = randucbmsqdt(t,~,T,betaK,s,IIpart)


wvalue=[s.w1(t,T),s.w2(t,T),s.w3(t,T),s.w4(t,T),s.w5(t,T),...
    s.w6(t,T),s.w7(t,T),s.w8(t,T),s.w9(t,T),s.w10(t,T),...
    s.w11(t,T),s.w12(t,T),s.w13(t,T),s.w14(t,T),s.w15(t,T),...
    s.w16(t,T),s.w17(t,T),s.w18(t,T),s.w19(t,T),s.w20(t,T),...
    s.w21(t,T),s.w22(t,T),s.w23(t,T),s.w24(t,T),s.w25(t,T),...
    s.w26(t,T),s.w27(t,T),s.w28(t,T),s.w29(t,T),s.w30(t,T)];
% IIpartvalue=[sum(wvalue(IIpart(:,1)==1)),sum(wvalue(IIpart(:,2)==1)),...
%     sum(wvalue(IIpart(:,3)==1)),sum(wvalue(IIpart(:,4)==1)),...
%     sum(wvalue(IIpart(:,5)==1)),sum(wvalue(IIpart(:,6)==1)),...
%     sum(wvalue(IIpart(:,7)==1)),sum(wvalue(IIpart(:,8)==1)),...
%     sum(wvalue(IIpart(:,9)==1)),sum(wvalue(IIpart(:,10)==1)),...
%     sum(wvalue(IIpart(:,11)==1)),sum(wvalue(IIpart(:,12)==1)),...
%     sum(wvalue(IIpart(:,13)==1)),sum(wvalue(IIpart(:,14)==1)),...
%     sum(wvalue(IIpart(:,15)==1)),sum(wvalue(IIpart(:,16)==1)),...
%     sum(wvalue(IIpart(:,17)==1)),sum(wvalue(IIpart(:,18)==1)),...
%     sum(wvalue(IIpart(:,19)==1)),sum(wvalue(IIpart(:,20)==1)),...
%     sum(wvalue(IIpart(:,21)==1)),sum(wvalue(IIpart(:,22)==1)),...
%     sum(wvalue(IIpart(:,23)==1)),sum(wvalue(IIpart(:,24)==1)),...
%     sum(wvalue(IIpart(:,25)==1)),sum(wvalue(IIpart(:,26)==1)),...
%     sum(wvalue(IIpart(:,27)==1)),sum(wvalue(IIpart(:,28)==1)),...
%     sum(wvalue(IIpart(:,29)==1)),sum(wvalue(IIpart(:,30)==1)),...
%     sum(wvalue(IIpart(:,31)==1)),sum(wvalue(IIpart(:,32)==1)),...
%     sum(wvalue(IIpart(:,33)==1)),sum(wvalue(IIpart(:,34)==1)),...
%     sum(wvalue(IIpart(:,35)==1)),sum(wvalue(IIpart(:,36)==1)),...
%     sum(wvalue(IIpart(:,37)==1)),sum(wvalue(IIpart(:,38)==1)),...
%     sum(wvalue(IIpart(:,39)==1)),sum(wvalue(IIpart(:,40)==1)),...
%     sum(wvalue(IIpart(:,41)==1)),sum(wvalue(IIpart(:,42)==1)),...
%     sum(wvalue(IIpart(:,43)==1)),sum(wvalue(IIpart(:,44)==1)),...
%     sum(wvalue(IIpart(:,45)==1)),sum(wvalue(IIpart(:,46)==1)),...
%     sum(wvalue(IIpart(:,47)==1)),sum(wvalue(IIpart(:,48)==1)),...
%     sum(wvalue(IIpart(:,49)==1)),sum(wvalue(IIpart(:,50)==1)),...
%     sum(wvalue(IIpart(:,51)==1)),sum(wvalue(IIpart(:,52)==1))];

rest=ones(1+2*betaK+betaK*(betaK-1)/2,1);
rest(1)=sum(wvalue(1:betaK).^2);
rest(2:betaK+1)=0;
rest(betaK+2:2*betaK+1)=sqrt(2)*wvalue(1:betaK).^2;
base=2*betaK+1;
for ii=1:betaK
    index=find(IIpart(:,ii)==1);
    rest(base+index)=rest(base+index)*wvalue(ii);
end
rest(2*betaK+2:2*betaK+1+betaK*(betaK-1)/2)=2*rest(2*betaK+2:2*betaK+1+betaK*(betaK-1)/2);
